var lengthOfLastWord = function (s) {
    console.log(s[0]);

    let s1 = '';
    let len = s.length - 1;
    console.log(len);

    for (let i = len; i >= 0; i--) {
        console.log(s[i]);

        if (i !== s.length - 1 && s[i + 1] !== ' ' && s[i] == ' ') {
            console.log("1");
            return s1.length;
        }
        if (s[i] == ' ') {
            console.log("2");
            continue;
        }
        if (s[i] !== ' ') {
            console.log(3);
            s1 += s[i];
        }
    }
    // return s1.length;
    console.log(s1);

};

s = 'a';
lengthOfLastWord(s);